package view;

import java.math.BigDecimal;

import javax.faces.bean.ManagedBean;

import business.CalculadoraIrpf;
import business.Irpf;
import business.TabelaIrpf2012;

@ManagedBean
public class IrpfCalculateForm {

	private Irpf irpf;
	private CalculadoraIrpf calculadora;
	private TabelaIrpf2012 tabela;
	
	public IrpfCalculateForm(){
		irpf = new Irpf();
		tabela = new TabelaIrpf2012();
		calculadora = new CalculadoraIrpf(tabela);
	}

	public Irpf getIrpf() {
		return irpf;
	}

	public void setIrpf(Irpf irpf) {
		this.irpf = irpf;
	}
	
	public void calculateIrpf(){
		irpf.setTotal(calculadora.calculaIrpf(new BigDecimal(irpf.getBase())).toString());
	}
	
	public void restoreIrpf(){
		irpf.setBase("0");
		irpf.setTotal(calculadora.calculaIrpf(new BigDecimal(irpf.getBase())).toString());
	}
}
